<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Server-Sent</title>
</head>
<body>
<h1>Server-Sent开始</h1>
<div id="result"></div>

<h2>Server-Sent结束</h22>
</body>
</html>

<script>
if(typeof(EventSource)!=="undefined")
  {
  var source=new EventSource("demo_sse.asp");
  console.log(source)
  source.onmessage=function(event)
    {
    document.getElementById("result").innerHTML+=event.data + "<br />";
    };
  }
else
  {
  document.getElementById("result").innerHTML="抱歉，您的浏览器不支持 server-sent 事件 ...";
  }
</script>

